<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="__EXTEND__/favicon.ico" >
	<link rel="Shortcut Icon" href="__EXTEND__/favicon.ico" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="__EXTEND__/lib/html5shiv.js"></script>
	<script type="text/javascript" src="__EXTEND__/lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="__EXTEND__/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
	<script type="text/javascript" src="__EXTEND__/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>账号管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> <a style='color:#2a4f92' href="{{:U('Admin/Index/welcome')}}">首页</a>  <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 账号管理
	<a class="btn btn-default radius r " id="btn-refresh" style="line-height:1.6em;margin-top:3px" href="{{:U('Admin/Member/Index')}}" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form id="searchform" action="{{:U('Admin/Member/Index')}}" method="post">
		<div class="cl">
			UID:
			<input type="text" value="{{$searchs['uid']}}" name="uid" id="uid" placeholder=" 请输入UID" style="width:200px" class="input-text">
			昵称:
			<input type="text" value="{{$searchs['nickname']}}" name="nickname" id="nickname" placeholder=" 请输入昵称" style="width:200px" class="input-text">
			所属部门：
			<span class="select-box inline">
                    <select name="d_id" class="select">
                        <option value="all">全部部门</option>
                        <foreach name="departments" item = "depart">
                            <option value="{{$depart['id']}}" <if condition = "$searchs['d_id'] eq $depart['id']"> selected</if>>{{$depart['name']}}</option>
                        </foreach>
                    </select>
                </span>
			<button type="submit" class="btn btn-primary radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 筛选</button>
		</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="admin_add('添加账号','{{:U('Admin/Member/add')}}','780','450')" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 添加账号
            </a>
        </span>
		<span class="r">{{$_page}}</span>
	</div>
	<table class="table table-border table-bordered table-bg mt-20 table-sort table-hover table-striped">
		<thead>
		<tr class="text-c">
			<th style=""><input type="checkbox" name="" value=""></th>
			<th style="">UID</th>
			<th style="">所属部门</th>
			<th style="">账号</th>
			<th style="">手机号码</th>
			<th style="">登录次数</th>
			<th style="">最后登录时间</th>
			<th style="">最后登录IP</th>
			<th style="">状态</th>
			<th style="">角色</th>
			<th style="">操作</th>
		</tr>
		</thead>
		<tbody>
			<notempty name="lists">
				<volist name="lists" id="vo">
					<tr class="text-c" <if condition="$vo['uid'] eq C('USER_ADMINISTRATOR')">style="display:none"</if>>
					<td><input class="ids" type="checkbox" name="id[]" value="{{$vo.uid}}" /></td>
					<td>{{$vo.uid}} </td>
					<td>
						<if condition="$vo['d_id'] eq 0">
							开发人员
							<else/>
							{{$vo.depart_name}}
						</if>
					</td>
					<td>{{$vo.nickname}}</td>
					<td class="logistic" onclick="showinput(this,'{{$vo['uid']}}','mobile')">
						<span class="mobile{{$vo['uid']}}"  style="cursor:pointer">
							{{$vo.mobile}}
						</span>
						<span class="imobile{{$vo['uid']}}" style="display:none">
						   <input type="text" name="mobile[]" value="{{$vo['mobile']}}" onchange="changeField(this,'{{$vo['uid']}}','mobile')" onblur="hideinput(this,'{{$vo['uid']}}','mobile')" style="width:80px;height:25px;"/>
						</span>
					</td>
					<td>{{$vo.login}}</td>
					<td><span><if condition="$vo['last_login_time']">{{$vo.last_login_time|time_format}}<else/>未登录</if></span></td>
					<td><span>{{:long2ip($vo['last_login_ip'])}}</span></td>
					<td class="td-status">
						<if condition="$vo['status'] eq 1">
								<span class="label label-primary radius">启用</span>
							<else/>
								<span class="label label-default radius">禁用</span>
						</if>
					</td>
					<td>
						<if condition="$vo['uid'] eq 1">
							开发人员
							<else/>
							{{$vo.title}}
						</if>
					</td>
					<td class="td-manage">
						<if condition="$vo['status'] eq 1">
							<a style="text-decoration:none" onClick="user_stop(this,{{$vo['uid']}})" href="javascript:;" title="停用">
								<i class="Hui-iconfont">&#xe631;</i>
							</a>
							<else/>
							<a style="text-decoration:none" onClick="user_start(this,{{$vo['uid']}})" href="javascript:;" title="启用">
								<i class="Hui-iconfont">&#xe615;</i>
							</a>
						</if>
						<a title="修改密码" href="javascript:;" onclick="do_show('修改密码','{{:U('Admin/Member/updatePwd')}}','650','350')" class="ml-5" style="text-decoration:none">
							<i class="Hui-iconfont">&#xe60c;</i>
						</a>
						<a title="删除" href="javascript:;" onclick="user_del(this,{{$vo['uid']}})" class="ml-5" style="text-decoration:none">
							<i class="Hui-iconfont">&#xe6e2;</i>
						</a>
						<a href="javascript:;" onclick="group_add('分配角色','{{:U('Admin/AuthManager/groupAccess',array('uid'=>$vo['uid']))}}','650','250')" class="">
							分配角色
						</a>
						<!--<a href="{{:U('AuthManager/user?group_name='.$vo['title'].'&group_id='.$vo['id'])}}" >成员授权</a>-->
					</td>
				</tr>
			</volist>
				<tr>
					<td scope="col" colspan="60" >
						<span class="r" >{{$_page}}</span>
					</td>
				</tr>
				<else/>
				<tr><td colspan="60" class="text-center">  暂时还没有内容! </td></tr>
			</notempty>
		</tbody>
	</table>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__EXTEND__/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__EXTEND__/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__EXTEND__/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__EXTEND__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/laypage/1.2/laypage.js"></script>
<!--<script type="text/javascript" src="__EXTEND__/js/checkauth.js"></script>-->
<script>
    function showinput(obj,id,field){
        $('.'+field+id).hide();
        $('.i'+field+id).show();
        $('.i'+field+id+' input').focus();
    }
    function hideinput(obj,id,field){
        $('.'+field+id).show();
        $('.i'+field+id).hide();
    }
    function changeField(obj,id,field){
        var values = '';
        values = $('.i'+field+id+' input').val();

        $.ajax({
            type: "POST",
            url: "{{:U('Admin/Member/changeField')}}",
            data: {
                id : id,
                field : field,
				value : values,
            },
            timeout:180000,
            dataType: "JSON",
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败!',{icon: 5,time:1000});
            },
            success: function(msg){
                if(msg["status"]==1){
                    layer.msg(msg.info, {icon: 6,time:1000});
                    $(obj).parents("tr").find(".logistic").html(values);
                }else{
                    layer.msg(msg.info,{icon: 5,time:1000});
                }
            }
        });
        $('.'+type+uuid).show();
        $('.i'+type+uuid).hide();
    }
</script>

<script type="text/javascript">
    function do_show(title,url,w,h){
        layer_show(title,url,w,h);
    }



    /*管理员-删除*/
    function user_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
				url: "{{:U('Admin/Member/changeStatus')}}",
					data: {
					method : 'deleteUser',
						id : id
				},
                dataType: 'json',
                success: function(data){
                    if(data.status){
                        $(obj).parents("tr").remove();
                        layer.msg(data.info,{icon:1,time:1000});
                        setTimeout((function() {
                            window.location.href="{{:U('Admin/Member/index')}}";
                        }), 500);
					}else{
                        layer.msg(data.info,{icon:2,time:1000});
					}
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

    /*管理员-停用*/
    function user_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            $.ajax({
                type: "POST",
                url: "{{:U('Admin/Member/changeStatus')}}",
                data: {
                    method : 'forbidUser',
                    id : id
                },
                timeout:180000,
                dataType: "JSON",
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg('操作失败!',{icon: 5,time:1000});
                },
                success: function(msg){
                    if(msg["status"]==1){
                        $(obj).parents("tr").find(".td-manage").prepend('<a onClick="user_start(this,'+id+')" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">禁用</span>');
                        $(obj).remove();
                        layer.msg(msg.info,{icon: 6,time:1000});
                    }else{
                        layer.msg(msg.info,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

    /*管理员-启用*/
    function user_start(obj,id){
        layer.confirm('确认要启用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            $.ajax({
                type: "POST",
                url: "{{:U('Admin/Member/changeStatus')}}",
                data: {
                    method : 'resumeuser',
                    id : id
                },
                timeout:180000,
                dataType: "JSON",
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg('操作失败!',{icon: 5,time:1000});
                },
                success: function(msg){
                    if(msg["status"]==1){
                        $(obj).parents("tr").find(".td-manage").prepend('<a onClick="user_stop(this,'+id+')" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-primary radius">正常</span>');
                        $(obj).remove();
                        layer.msg(msg.info, {icon: 6,time:1000});
                    }else{
                        layer.msg(msg.info,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

    /*管理员-增加*/
    function admin_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*分配用户组*/
    function group_add(title,url,w,h){
        layer_show(title,url,w,h);
	}

</script>
</body>
</html>